'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.diffSet = exports.getSetDiff = undefined;

var _flatObj = require('./flatObj');

var _mapSet = require('./mapSet');

var _mapSet2 = _interopRequireDefault(_mapSet);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var diffObj = function diffObj(data, target) {
    var item = void 0;
    var tItem = void 0;
    var rst = {};
    for (var k in target) {
        item = data[k];
        tItem = target;
        if (item === tItem) {
            continue;
        }
        rst[k] = target[k];
    }
    return rst;
};

var getSetDiff = exports.getSetDiff = function getSetDiff(newData, oldData) {
    var newObj = (0, _flatObj.flatObj)(newData);
    var oldObj = (0, _flatObj.flatObj)(oldData);
    return diffObj(oldObj, newObj);
};

var diffSet = exports.diffSet = function diffSet(target, newData, oldData) {
    var diff = getSetDiff(newData, oldData);
    (0, _mapSet2.default)(target, diff);
};
exports.default = diffSet;